#pragma comment(linker, "/STACK:10000000")
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <cstdio>
#include <cassert>
#include <string>
#include <cstring>
#define ldb long double
#define ll long long
#define fi first
#define se second
#define fill(a, c) memset(a, c, sizeof(a))
#define sqr(a) ((a) * (a))
#define nextLine() {int c = 0; while((c = getchar()) != 10 && c != EOF);}
#define getBit(mask, k) (((mask) / pw[k]) % pw[1])
#define setBit(mask, k, l) (((mask) / pw[k + 1] * pw[1] + (l)) * pw[k] + ((mask) % pw[k]))
#define debug(a) cerr << #a << " = " << a << " ";
#define debugl(a) cerr << #a << " = " << a << "\n";
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define ff first
#define ss second 
const ldb LDINF = 9128739847123.00;
const ldb eps = 1e-9;
const int inf = 1 << 28;
const ldb pi = fabsl(atan2l(0.0, -1.0));
using namespace std;

char s[150000];
int n;

void load()
{
	gets(s);
	n = strlen(s);
}

#define MS 100010
int a[MS], c[MS], c2[MS], a2[MS], beg[MS], cnt[MS];
int lcp[MS], b[MS];


void kasai()
{
	for (int i = 0; i < n; i++)
		b[a[i]] = i;
	int i = 0, k = 0;
	for (i = 0; i < n; i++)
	{
		if (b[i] == n - 1)
		{
		    lcp[b[i]] = 0;
		    k = 0;
		    continue;
		}
		while (i + k < n && a[b[i] + 1] + k < n && s[i + k] == s[a[b[i] + 1] + k]) k++;
		lcp[b[i]] = k;
		k = max(k - 1, 0);
	}
}

void suffix_array()
{
 	int i, j, k;
 	s[n++] = '#';
 	for (i = 0; i < n; i++)
 	{
 		cnt[s[i]]++;
 	}
 	beg[0] = 0;
 	for (i = 1; i < 255; i++)
 		beg[i] = beg[i-1] + cnt[i-1];
 	for (i = 0; i < n; i++)
 		a[beg[s[i]]++] = i;
 	c[a[0]] = 0;
 	for (i = 1; i < n; i++)
 	{
 		c[a[i]] = c[a[i-1]];
 		if (s[a[i]] != s[a[i-1]])
 			c[a[i]]++;
 	}
 	int l = 1;
 	while (l <= n && c[a[n - 1]] < n) 
 	{
 		for (i = 0; i <= c[a[n - 1]]; i++)
 			cnt[i] = 0;
 		for (i = 0; i < n; i++)
 			cnt[c[a[i]]]++;
 		beg[0] = 0;
 		for (i = 1; i <= c[a[n - 1]]; i++)
 			beg[i] = beg[i-1] + cnt[i-1];
 		for (i = 0; i < n; i++)
 		{
 			j = a[i] - l;
 			if (j < 0) j += n;
 			a2[beg[c[j]]++] = j;
 		}
 		c2[a2[0]] = 0;
 		for (i = 1; i < n; i++)
 		{
 			j = (a2[i - 1] + l) % n;
 			k = (a2[i] + l) % n;
 			c2[a2[i]] = c2[a2[i-1]];
 			if (c[a2[i-1]] < c[a2[i]] || c[a2[i-1]] == c[a2[i]] && c[j] < c[k])
 			{
 				c2[a2[i]]++;
 			}
 		}
 		for (i = 0; i < n; i++)
 		{
 			a[i] = a2[i];
 			c[i] = c2[i];
 		}
 		l <<= 1;
 	}
 	n--;
 	for (int i = 0; i < n; i++)
 		a[i] = a[i + 1];
}

int f1[123123];
int f2[123123];
int tree[1 << 18];
int key[1 << 18];
int tsize;

void add1(int i, int pos)
{
	while (i <= n)
	{
		f1[i] = max(f1[i], pos);
		i |= i + 1;
	}
}

int get1(int i)
{
	int res = -1;
	while (i >= 0)
	{
		res = max(res, f1[i]);
		i = (i & (i + 1)) - 1;
	}
	return res;
}

void add2(int i, int pos)
{
	while (i <= n)
	{
		f2[i] = min(f2[i], pos);
		i |= i + 1;
	}
}

int get2(int i)
{
	int res = inf;
	while (i >= 0)
	{
		res = min(res, f2[i]);
		i = (i & (i + 1)) - 1;
	}
	return res;
}

int res[123123];
int p[123123];
vector <pair <int ,int > > ev;
int find(int i)
{
	if (p[i] != i) p[i] = find(p[i]);
	return p[i];
}

bool was[123123];

int cc[123123];

void solve()
{
	suffix_array();
	kasai();
	cerr << s << "\n";
	for (int i = 0; i < n; i++)
	{
		cerr << a[i] << " ";
	}
	cerr << "\n";
	for (int i = 0; i < n; i++)
	{
		cerr << lcp[i] << " ";
	}
	cerr << "\n";
	/*
	for (int i = 0; i < n; i++)
	{
		ev.pb(mp(-lcp[i], i));
	}
	sort(ev.begin(), ev.end());

	for (int i = 0; i < n; i++)
	{
		p[i] = i;
	}
	ll res = 0;
	int lst = n;
	for (int i = 0; i < n; i++)
	{
		ev[i].ff = -ev[i].ff;
		if (i && ev[i].ff != ev[i - 1].ff)
		{
			lst = ev[i - 1].ff - ev[i].ff;
			if (ev[i].ff == 0)
				lst--; 
		}
		was[ev[i].ss] = 1;
		if (ev[i].ss + 1 < n && was[ev[i].ss + 1] && ev[i].ss - 1 >= 0 && was[ev[i].ss - 1])
		{
			res += ((ll)cc[find(ev[i].ss + 1)] + 1) * ((ll)cc[find(ev[i].ss - 1)] + 2) * (ll)lst;
			cc[ev[i].ss] = cc[find(ev[i].ss + 1)] + cc[find(ev[i].ss - 1)] + 1;
			p[find(ev[i].ss + 1)] = ev[i].ss;
			p[find(ev[i].ss - 1)] = ev[i].ss;
		}
		else if (ev[i].ss + 1 < n && was[ev[i].ss + 1])
		{
			cc[find(ev[i].ss + 1)]++;
			res += (cc[find(ev[i].ss + 1)] + 1);
			p[ev[i].ss] = find(ev[i].ss + 1);
		}
		else if (ev[i].ss > 0 && was[ev[i].ss - 1])
		{
			cc[find(ev[i].ss - 1)]++;
			res += (cc[find(ev[i].ss - 1)] + 1);
			p[ev[i].ss] = find(ev[i].ss - 1);
		}
		else
		{
			cc[ev[i].ss] = 1;
			if (ev[i].ff != 0)
				res += 3;
			else res++;
		}
		cerr << res << "\n";
	}
	*/
	
	
	memset(f1, -1, sizeof(f1));
	for (int i = 0; i <= n; i++)
		f2[i] = inf;
	ll res = 0;
	for (int i = n - 1; i >= 0; i--)
	{
		int j = get2(lcp[i] - 1);
		if (res[i] == inf) res[i] = n;
		add2(lcp[i], i);

	}
	cout << res;
}

#define file "d"
int main()
{
	#ifndef ONLINE_JUDGE
		freopen(file".in", "rt", stdin);
		freopen(file".out", "wt", stdout);
	#endif
	load();
	solve();
	return 0;
}
